package com.xinan.tool.aoi.controller;


import com.xinan.tool.aoi.entity.AoiTableConfig;
import com.xinan.tool.aoi.service.IAoiDealService;
import io.swagger.annotations.ApiOperation;
import org.apache.hc.core5.http.ParseException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yuanzheng
 * @since 2025-08-26
 */
@RestController
@RequestMapping("/aoi/tool")
public class AoiDealController {

    @Resource
    private IAoiDealService aoiDealService;

    @PostMapping("/transGcj02ToWgs84")
    @ApiOperation(value = "坐标系转换（GCJ02->WGS84）", tags = {"坐标系转换"})
    public String transGcj02ToWgs84(AoiTableConfig aoiTableConfig) {
        // 进行坐标转换后更新源表数据
        return aoiDealService.transGcj02ToWgs84(aoiTableConfig);
    }

    @PostMapping("/getAoiByName")
    @ApiOperation(value = "通过小区名称获取AOI数据", tags = {"数据获取"})
    public String getAoiByName(AoiTableConfig aoiTableConfig) {
        return aoiDealService.getAoiByName(aoiTableConfig);
    }

    @PostMapping("/getBaiDuAoi")
    @ApiOperation(value = "获取百度AOI", tags = {"数据获取"})
    public String getBaiDuAoi(String region, String addressStr, boolean useKey) throws IOException, ParseException {
        return aoiDealService.getBaiDuAoi(region, addressStr, useKey);
    }


}

